<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    class Queue {
      constructor() {
        this.queue = [];
      }

      enqueue(value) {
        this.queue.push(value);
      }

      dequeue() {
        return this.queue.shift();
      }

      peek() {
        return this.queue[0];
      }

      isEmpty() {
        return this.queue.length === 0;
      }

      size() {
        return this.queue.length;
      }
    }

    let queue = new Queue();
    queue.enqueue(1);
    queue.enqueue(2);
    queue.enqueue(3);
    console.log(queue.peek()); // 输出1
    console.log(queue.dequeue()); // 输出1
    console.log(queue.dequeue()); // 输出2

  </script>
</body>

</html>